function minWindow(s: string, t: string): string {
    let map:Map<string,number> = new Map()
    for (let i = 0; i < t.length; i++) {
        if (map.has(t[i])) {
            let count = map.get(t[i]) + 1
            map.set(t[i], count)
        } else {
            map.set(t[i], 1)
        }
    }
    let l = 0,
        need = t.length,
        res = ''
    for (let r = 0; r < s.length; r++) {
        if (map.has(s[r])) {
            if (map.get(s[r]) > 0) {
                need--
            }
            let count = map.get(s[r]) - 1
            map.set(s[r], count)
        }
        if(need==0){
            while (need == 0) {
                if (map.has(s[l])) {
                    let count = map.get(s[l]) + 1
                    map.set(s[l], count)
                    if(count>0){
                        need++
                    }
                }
                l++
            }
            let newRes = s.slice(l,r+1)
            res = (res && (res.length<newRes.length)) ? res : newRes
        }
    }
    return res
};